//
//  CZComment.swift
//  GZWeibo007
//
//  Created by danli on 15/12/24.
//  Copyright © 2015年 Apple. All rights reserved.
//

import UIKit

///评论模型
class CZComment: NSObject
{
    /// 属性
    /// 创建时间
    var created_at:String?
    
    /// 评论的ID
    var id: Int = 0
    
    /// 评论的内容
    var text:String?
    
    /// 评论作者
    var user:CZUser?
    
    override init(){
        super.init()
    }
    
    init(dic:[String: AnyObject])
    {
        super.init()
        setValuesForKeysWithDictionary(dic)
    }
    
    /// 忽略没有的key
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
        
    }
    
    override func setValue(value: AnyObject?, forKey key: String) {
        if key == "user"
        {
            //字典转模型
            if let dict = value as? [String: AnyObject] {
                let userModel = CZUser(dict: dict)
                self.user = userModel
            }
            return
        }
        
        super.setValue(value, forKey: key)
    }
    
    override var description: String {
        let prop = ["created_at", "id", "text", "user"]
        let dict = dictionaryWithValuesForKeys(prop)
        return "\n\t评论模型:\(dict)"
    }
}
